<template>
  <div class="my-radio-container"
  >
    <input
      type="radio"
      :id="uniqueId"
      :name="radioName"
      :value="label"
      :checked="label === value"
      @change="changeValue"
      hidden
    />
    <label class="my-radio-label" :for="uniqueId">
    </label>
  </div>
</template>

<script>
export default {
  name: 'MyRadio',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      required: true
    },
    label: {
      required: true
    },
    radioName: {
      required: false
    }
  },
  data() {
    return {
      uniqueId: `radio-${Math.random().toString(36).substr(2, 9)}`
    }
  },
  methods: {
    changeValue() {
      this.$emit('change', this.label)
    }
  }
}
</script>

<style scoped lang="scss">
$normalBorderColor: #DCDFE6;
.my-radio-container {
  display: inline-block;
  position: relative;
  height: 20px;
  width: 20px;
  text-align: center;
  vertical-align: middle;

  .my-radio-label {
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid $normalBorderColor;
    box-shadow: 0px 0px 3px $normalBorderColor;
    transform: translate(-50%, -50%);

    &:hover {
      border: 1px solid rgb(27, 154, 238);
    }
  }

  input:checked + .my-radio-label {
    border: 4px solid rgb(27, 154, 238);
  }
}
</style>
